<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ph="http://java.sun.com/jsf/composite/pharmacy/inward">

    <ui:define name="content">
        <h:form>
            <h:outputStylesheet library="css" name="pharmacyA4.css"/>
            <h:panelGroup rendered="#{!storeBhtIssueReturnController.printPreview}" styleClass="alignTop" >
                <p:panel>

                    <f:facet name="header" >      

                        <h:panelGrid columns="15"  >                                                     

                            <p:commandButton  value="Return" 
                                             action="#{storeBhtIssueReturnController.settle}" 
                                            ajax="false" 
                                              style="width: 150px; padding: 1px;border: 1px solid ; margin: auto;" onclick="onSubmitButton();" >
                            </p:commandButton>
                            <p:outputLabel  value="Recievable Amount" rendered="#{webUserController.hasPrivilege('ShowInwardFee')}" /> 
                            <p:outputLabel id="total"  value="#{storeBhtIssueReturnController.returnBill.total}" style="float: right;"
                                           rendered="#{webUserController.hasPrivilege('ShowInwardFee')}"/> 
                        </h:panelGrid>
                    </f:facet>
                </p:panel>

                <p:dataTable var="ph" value="#{storeBhtIssueReturnController.billItems}"
                             scrollable="true" scrollHeight="250"
                             id="itemList" >  

                    <f:facet name="header">  
                        Returning Item 
                    </f:facet>  


                    <p:column headerText="Item Name" style="width:50px!important;">  
                        <h:outputText value=" #{ph.item.name}"  />                     

                    </p:column>  

                    <p:column headerText="Ballance Qty in Unit" style="width:25px!important;"> 
                        <h:outputText value="#{ph.pharmaceuticalBillItem.qty}" />                   
                    </p:column>  

                    <p:column headerText="Purchase Rate" style="width:25px!important;"> 
                        <h:outputText value="#{ph.rate}"  />                        
                    </p:column>                 


                    <p:column headerText="Bathch No" style="width:25px!important;">                       
                        <h:outputText value="#{ph.pharmaceuticalBillItem.stringValue}" />                        
                    </p:column>  

                    <p:column headerText="Date of Expirey" style="width:25px!important;">                     
                        <h:outputText value="#{ph.pharmaceuticalBillItem.doe}" /> 
                    </p:column>


                    <p:column headerText="Returning Qty in Unit" style="width:25px!important;">                     
                        <p:inputText autocomplete="off" value="#{ph.qty}" >
                            <f:ajax event="keyup" render="@this :#{p:component('total')}"  execute="@this" listener="#{storeBhtIssueReturnController.onEdit(ph)}" ></f:ajax>
                        </p:inputText>
                    </p:column>  

                </p:dataTable>  
                <p:spacer height="50"/>

            </h:panelGroup>

            <p:panel rendered="#{storeBhtIssueReturnController.printPreview}">
                <p:commandButton ajax="false" action="store_search_sale_bill_bht" value="Store Issue Search" actionListener="#{storeBhtIssueReturnController.makeNull}" onclick="onSubmitButton();" />                    
                <p:commandButton value="Print Return Bill" ajax="false" action="#"  >
                    <p:printer target="gpBillPreview1" ></p:printer>
                </p:commandButton>
                <p:commandButton value="Print Sale Bill" ajax="false" action="#"   >
                    <p:printer target="gpBillPreview2" ></p:printer>
                </p:commandButton>
                <p:panel   id="gpBillPreview1"   >
                    <ph:returnBill bill="#{storeBhtIssueReturnController.returnBill}"/>                
                </p:panel>
                <p:panel   id="gpBillPreview2"   >
                    <ph:issueBill  bill="#{storeBhtIssueReturnController.bill}"/>                
                </p:panel>
            </p:panel>

        </h:form>
    </ui:define>  

</ui:composition>
